<template>
  <div v-if="viewModel">
    <base-setting v-if="viewModel" v-model="viewModel"></base-setting>
    <el-form-item label="二维码文字" required>
      <el-input v-model="viewModel.text" placeholder="请输入二维码文字内容" :max="255" size="mini"></el-input>
      <div class="sale-intro">二维码文字内容，可以使网址、微信号、公众号、文字等内容。不能超过255个字</div>
    </el-form-item>
    <el-form-item label="二维码大小" required>
      <el-input-number :min="9" :max="500" v-model="viewModel.size" size="mini"></el-input-number>
      <div class="sale-intro">二维码大小,长度和宽度一样</div>
    </el-form-item>
    <el-form-item label="二维码背景色">
      <el-color-picker v-model="viewModel.backgroundColor" size="mini"></el-color-picker>
      <div class="sale-intro">二维码背景色</div>
    </el-form-item>
    <el-form-item label="二维码背景色">
      <el-color-picker v-model="viewModel.foreground" size="mini"></el-color-picker>
      <div class="sale-intro">二维码前景色</div>
    </el-form-item>
    <el-form-item label="二维码图标">
      <x-select-image v-model="viewModel.icon"></x-select-image>
      <div class="sale-intro">二维码中心的图片</div>
    </el-form-item>
  </div>
</template>
<script>
  import baseSetting from './base'
  import ala from 'ala'
export default {
    model: {
      prop: 'dataModel',
      event: 'change'
    },
    components: {
      baseSetting
    },
    props: {
      dataModel: {}
    },
    data () {
      return {
        viewModel: null
      }
    },
    mounted () {
      this.init()
    },
    methods: {
      async init () {
        this.viewModel = this.dataModel
      }
    },
    watch: {
      viewModel: {
        deep: true,
        handler (val) {
          this.$emit('change', this.viewModel)
        }
      }
    }
  }
</script>
